from flask import Flask, redirect, url_for, request, render_template,flash,make_response
import os
from werkzeug.utils import secure_filename

app = Flask(__name__)

app.config['UPLOAD_FOLDER'] = os.path.join(os.environ['USERPROFILE'], 'Desktop\\')

#app.secret_key='123456789'

@app.route('/')
def index():
   return redirect(url_for('upload_file'))

@app.route('/upload')
def upload_file():
   return render_template('upload.html')

@app.route('/uploader', methods = ['GET', 'POST'])
def uploader():
   if request.method == 'POST':
      f = request.files['file']
      print(request.files)
      f.save(os.path.join(app.config['UPLOAD_FOLDER'],secure_filename(f.filename)))
      return 'File uploaded successfully'
   else:
      return render_template('upload.html')


if __name__ == '__main__':
    app.run(port=1212)